package com.maoslv.mapper;

import com.maoslv.pojo.Role;
import com.maoslv.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface UserMapper {
    //注册用户
    int registerUser(User user);

    //查询用户名是否存在
    User queryUsername(String username);

    //通过用户名查询用户
    User getByUsername(String username);

    //通过用户Id获取角色
    List<String> getRoleById(Integer id);

    //通过用户Id获取操作权限
    List<String> getPermsById(Integer id);

    List<User> getUserList(Map<String,Object> userMap);

    List<Role> getUserRole(Integer id);

    User getUserInfo(Integer id);

    int updateUser(Map<String,Object> userMap);

//    int delUser(Integer id);

    List<Role> getAllRole();

    List<Integer> getRoleId(Integer id);

    int addRole(@Param("id") Integer id, @Param("list")List<Integer> list);

    int delRole(@Param("id") Integer id, @Param("list")List<Integer> list);

    int autoAssignRole(Integer id);

    User getUserById(Integer id);
}
